<?php
declare (strict_types=1);

namespace app\common\model;

class BusinessRole extends Base
{
    protected $name = 'business_auth_group';

    public static function _all($map, $param): array
    {
        try {
            $page = $param['page'] ?? 1;
            $limit = $param['limit'] ?? 10;

            if(!isset($map['is_del'])){
                $map['is_del'] = 0;
            }
            $c = $that = parent::where(['is_del'=>0])->where(function ($query) use ($map){
                $query->where('id',1)->whereOr('business_id', $map['business_id']);
            });

            $list = $that->page(intval($page), intval($limit))->field('*')->select();

            return ['code' => 0, 'data' => $list, 'count' => $c->count()];

        } catch (\Exception $e) {
            dump($e);
            die;
            return [];
        }
    }

}
